#include <stdio.h>
#include <string.h>

char charset1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char charset2[] = "abcdefghijklmnopqrstuvwxyz";
char charset3[] = "~!@#$%^&*()-=";
char charset4[] = "0123456789";

int validate(char* pwd){
  if (strlen(pwd) < 8) {
    return -1;
  }
  int g1 = 0;
  int g2 = 0;
  int g3 = 0;
  int g4 = 0;

  for(int i=0;i<strlen(pwd);i++){
    if (strchr(charset1,pwd[i]) != 0) {
      g1 = 1;
    }
    if (strchr(charset2,pwd[i]) != 0) {
      g2 = 1;
    }
    if (strchr(charset3,pwd[i]) != 0) {
      g3 = 1;
    }
    if (strchr(charset4,pwd[i]) != 0) {
      g4 = 1;
    }
  }
  return (g1 + g2 + g3 + g4) >= 3 ? 1 : -1;
}

int main() {
  char buf[1024];
  while (scanf("%s", buf) != EOF) {
    if (strcmp("END", buf) == 0) {
      return 0;
    }
    puts(validate(buf) == -1 ? "NO" : "YES");
  }
}